using System;
using System.Collections.Generic;
using IQIGame.Onigao.Framework;
using NetProtocol.Enum;
using NetProtocol.POD;

namespace IQIGame.Onigao.GamePlay
{
    public class FriendData : IReusableClass
    {
        /// <summary>
        /// 唯一id
        /// </summary>
        public long id { get; protected set; }
        /// <summary>
        ///  玩家GUID
        /// </summary>
		public int guid;
        /// <summary>
        /// 玩家id
        /// </summary>
        public long pid { get; protected set; }
        /// /// <summary>
        ///  昵称
        /// </summary>
        public string playerName;
        /// <summary>
        ///  头像
        /// </summary>
        public int avatar;
        /// <summary>
        ///  玩家等级
        /// </summary>
        public int level;
        /// <summary>
        ///  是否在线
        /// </summary>
        public bool online;
        /// <summary>
        ///  目标备注
        /// </summary>
        public string remark;
        /// <summary>
        ///  好友类型
        /// </summary>
        public FriendType type;
        /// <summary>
        ///  创建时间
        /// </summary>
        public int createTime;
        /// <summary>
        ///  最后登录时间
        /// </summary>
        public int lastLoginTime;
        /// <summary>
        ///  游戏服务器ID
        /// </summary>
        public string gameServerId;
        /// <summary>
        ///  头像框
        /// </summary>
        public int avatarFrame;
        /// <summary>
        ///  称号
        /// </summary>
        public int title;

        #region 配置 && 逻辑

        #endregion
        public FriendData Sync(FriendPOD pod)
        {
            this.id = pod.id;
            this.pid = pod.pid;
            this.playerName = pod.playerName;
            this.createTime = pod.createTime;
            this.level = pod.level;
            this.avatar = pod.avatar;
            this.online = pod.online;
            this.remark = pod.remark;
            this.createTime = pod.createTime;
            this.avatar = pod.avatar;
            this.avatarFrame = pod.avatarFrame;
            this.title = pod.title;
            this.lastLoginTime = pod.lastLoginTime;
            this.type = pod.type;

            return this;
        }



        public void Clear()
        {
            this.id = 0;
            this.guid = 0;
            this.pid = 0;
            this.playerName = null;
            this.avatar = 0;
            this.level = 0;
            this.online = false;
            this.remark = null;
            this.type = default;
            this.createTime = 0;
            this.lastLoginTime = 0;
            this.gameServerId = null;
            this.avatarFrame = 0;
            this.title = 0;
        }

        #region 对象池
        public uint MaxStore => 100;

        public void OnReset()
        {
            this.Clear();
        }

        public void Put2Pool()
        {
            ClassPool.PutAutoType(this);
        }

        static public FriendData NewFromPool()
        {
            return ClassPool<FriendData>.Get();
        }
        #endregion

    }
    public class FriendModuleData
    {
        public List<Dictionary<long, FriendData>> dictionaries;
        public Dictionary<long, FriendData> dicCurrFriends { get; set; }

        public Dictionary<long, FriendData> dicCurrBlack { get; set; }
        public Dictionary<long, FriendData> dicCurrApply { get; set; }
        public Dictionary<long, FriendData> dicCurrMyApply { get; set; }
        public Dictionary<long, FriendData> dicSearchRes { get; set; }
        public FriendModuleData()
        {
            dicCurrFriends = new Dictionary<long, FriendData>();
            dicSearchRes = new Dictionary<long, FriendData>();
            dicCurrBlack = new Dictionary<long, FriendData>();
            dicCurrApply = new Dictionary<long, FriendData>();
            dicCurrMyApply = new Dictionary<long, FriendData>();
            dictionaries = new List<Dictionary<long, FriendData>>
    {
        dicCurrFriends,
        dicSearchRes,
        dicCurrBlack,
        dicCurrApply,
        dicCurrMyApply
    };
        }
        public void Clear()
        {
            foreach (var dic in dictionaries)
            {
                foreach (var item in dic.Values)
                {
                    item.Put2Pool();
                }
                dic.Clear();
            }
        }


    }
}
